<template>
    <scroll-view 
        :scroll-y="true"
        class="mz_docter_view">
        <view class="container">
            <view class="find">
                <u-search
                    shape="square"
                    @search="getData"
                    v-model="findData"
                    :show-action="false"
                    :height="80"
                    placeholder="请输入挂号单">
                </u-search>
                <u-loading
                    v-if="loading"
                    mode="flower">
                </u-loading>
            </view>
            <u-table>
                <u-tr>
                    <u-th>挂号单</u-th>
                    <u-th>姓名</u-th>
                    <u-th>年龄</u-th>
                    <u-th>科室</u-th>
                    <u-th>号类</u-th>
                </u-tr>
                <u-tr 
                    v-for="(item,index) in dataList" 
                    :key="index"
                    @click.native="findDetail(item)">
                    <u-td>{{item['挂单号']}}</u-td>
                    <u-td>{{item['姓名']}}</u-td>
                    <u-td>{{item['年龄']}}</u-td>
                    <u-td>{{item['科室']}}</u-td>
                    <u-td>{{item['号类']}}</u-td>
                </u-tr>
            </u-table>
            <u-toast ref="uToast" />
        </view>
    </scroll-view>
</template>

<script>
//门诊医生首页
import {getRgisterByRid} from "@/common/api";
export default {
    data() {
        return {
            findData:"", //根据挂号单查询挂单病人
            dataList:[], //数据列表
            loading:false,
        }
    },
    onShow(){
        this.getData();
    },
    methods: {
        findDetail(item){ //查看详情
            uni.navigateTo({
                url: '/pages/mz_docter/views/details?'
                    +'kid='+item['就诊卡号']
                    +'&Rid='+item['挂单号'],
            });
        },
        getData(){ //获取挂号单数据
            this.loading = true;
            getRgisterByRid(
                this.findData,
            ).then(data=>{
                this.dataList = data;
            }).catch(msg=>{
                this.$refs.uToast.show({
                    title: msg,
                    position:'top',
                    type: 'error',
                });
            }).finally(()=>{
                this.loading = false;
            });
        },
    },
}
</script>
<style scoped lang="scss">
.mz_docter_view{
    height: calc(100vh - 90rpx);
    .container{
        padding: 35rpx;
        box-sizing: border-box;
        >.find{
            display: flex;
            align-items: center;
            margin-bottom: 35rpx;
        }
        .u-table{
            display: block;
        }
    }
}
</style>
